package com.hb.trade.server.project.deal.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hb.core.pojo.parent.PageResult;
import com.hb.core.pojo.project.deal.dto.BidCandidateDTO;
import com.hb.core.pojo.project.deal.dto.BidCandidateSectionDTO;
import com.hb.core.pojo.project.deal.entity.BidCandidateSection;
import com.hb.core.pojo.project.deal.mapper.BidCandidateSectionMapper;
import com.hb.core.pojo.project.section.entity.BidSection;
import com.hb.trade.server.project.deal.service.BidCandidateSectionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 中标候选人公示-标段关联关系Service实现类
 *
 * @author Lix1ang
 * @date 2021-12-28 14:19:04
 */
@Service
public class BidCandidateSectionServiceImpl extends ServiceImpl<BidCandidateSectionMapper, BidCandidateSection> implements BidCandidateSectionService {

    @Override
    public PageResult<BidSection> getSectionNotSelected(BidCandidateDTO bidCandidateDTO) {
        Page<BidSection> sectionNotSelectedPage = baseMapper.pageSectionNotSelected(bidCandidateDTO.pages(), bidCandidateDTO);
        return PageResult.get(sectionNotSelectedPage);
    }

    @Override
    public PageResult<BidCandidateSectionDTO> listSectionByCandidateId(Page page, Long candidateId) {
        if (null == candidateId) {
            return PageResult.get();
        }
        Page pageSection = baseMapper.listSectionByCandidateId(page, candidateId);
        return PageResult.get(pageSection);
    }


    @Override
    public List<BidCandidateSection> listBidCandidateByCandidateId(Long candidateId) {
        if (candidateId == null){
            return CollUtil.list(false);
        }
        QueryWrapper<BidCandidateSection> wrapper = BidCandidateSection.wrapper();
        wrapper.eq("candidate_id",candidateId);
        return list(wrapper);
    }
}
